#include "update_redis_task.h"

#include "base/logging.h"
#include "im/common/common.h"

#include "redis_user_profile_adapter.h"

namespace imserver {

UpdateRedisTask::UpdateRedisTask(int64_t uid, int ttl) : redis_ttl_(ttl) {
  std::stringstream ss;
  ss << uid;

  user_profile_.__set_qid(uid);
  user_profile_.__set_username(ss.str());
  user_profile_.__set_nickname(ss.str());
  user_profile_.__set_head_pic(kDefaultHeadPic);
}

void UpdateRedisTask::run() {
  LOG_DEBUG("uid " << user_profile_.qid << " redis added.");
  RedisUserProfileAdapter::Instance().Add(user_profile_, redis_ttl_);
}

}


